/*
day284
2020.6.7
*/
#include<string>
#include<map>
using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s) {
		if(s.size()==0)
		{
			return 0;
		}
		map<char,int> m;
		int l=0,r=0,max=1;
		
		while(r<s.size())
		{
			m[s[r]]++;
			while(r<s.size() && !(isok(m)))
			{
				m[s[l]]--;
				l++;
				r++;
				m[s[r]]++;
			}
			
			if(isok(m))
			{
				max=r-l+1;
			}
			
			r++;
		}
		return max;
    }
    
    bool isok(map<char,int> &m)
    {
    	for(auto p:m)
    	{
    		if(p.second>1)
    		{
    			return false;
			}
		}
		return true;
	}
};


int main()
{
	return 0;
 } 
